#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[20][20][2];
int a[20];

ll dfs(int pos, int f, bool limited, bool head, int num) {
    if (pos < 0) return f && num >= 0;
    ll& val = dp[pos][num][f];
    if (val != -1 && !head && !limited) return val;
    int up = limited ? a[pos] : 9;
    ll sum = 0;
    for (int i = 0; i <= up && f; i++) {
        if (head && !i)
            sum += dfs(pos - 1, 1, limited && i == up, 1, num - 1);
        else
            sum += dfs(pos - 1, ((num - pos) & 1) != (i & 1),
                       limited && i == up, 0, num);
    }
    if (!limited && !head) val = sum;
    return sum;
}

ll work(ll x) {
    int pos = 0;
    while (x) {
        a[pos++] = x % 10;
        x /= 10;
    }
    return dfs(pos - 1, 1, 1, 1, pos - 1);
}

int main() {
    memset(dp, -1, sizeof(dp));
    int T, kase = 1;
    cin >> T;
    for (; kase <= T; kase++) {
        ll l, r;
        cin >> l >> r;
        // cout << work(l) << ' ' << work(r) << endl;
        cout << "Case #" << kase << ": " << work(r) - work(l - 1) << endl;
    }
}